from pydantic import BaseModel
from typing import Optional, List, Dict, Any
from datetime import datetime

# 问题基础模型
class IssueBase(BaseModel):
    title: str
    description: str
    type: str  # customer, internal
    category: str  # hardware, software, firmware等
    priority: str  # low, medium, high, urgent

# 问题创建模型
class IssueCreate(IssueBase):
    pass

# 问题更新模型
class IssueUpdate(BaseModel):
    title: Optional[str] = None
    description: Optional[str] = None
    type: Optional[str] = None
    category: Optional[str] = None
    priority: Optional[str] = None
    status: Optional[str] = None
    assignee_id: Optional[int] = None

# 问题数据库模型
class IssueInDB(IssueBase):
    id: int
    status: str  # open, in_progress, resolved, closed, rejected
    submitter_id: int
    assignee_id: Optional[int] = None
    similarity_score: Optional[float] = None
    matched_case_id: Optional[int] = None
    created_at: datetime
    updated_at: datetime
    closed_at: Optional[datetime] = None

    class Config:
        orm_mode = True

# 问题响应模型
class IssueResponse(IssueInDB):
    attachments: Optional[List[Dict[str, Any]]] = []